package com.itheima.advantagesup.controller;

import com.itheima.advantagesup.common.PageBean;
import com.itheima.advantagesup.common.R;
import com.itheima.advantagesup.dto.UserDataListDTO;
import com.itheima.advantagesup.dto.UserUpdateDTO;
import com.itheima.advantagesup.dto.UserUpdateInfoDTO;
import com.itheima.advantagesup.entity.YddArticle;
import com.itheima.advantagesup.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RequestMapping("/user")
@RestController
public class UserController {

    @Autowired
    private UserService userService;
    /**
     * 修改用户资料
     */
    @PostMapping("/update")
    public R update(@RequestBody UserUpdateInfoDTO userUpdateInfoDTO){
        userService.update(userUpdateInfoDTO);
        return R.success();
    }

    /**
     * 收藏点赞文章
     */
    @GetMapping("/userDataList")
    public R<Map<String,PageBean>> selectDataList(@RequestBody UserDataListDTO userDataListDTO){
        PageBean pageBean= userService.selectDataList(userDataListDTO);
        HashMap<String, PageBean> map = new HashMap<>();
        map.put("List",pageBean);
        return R.success(map);
    }
}
